// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   InsMod.java

package include.nseer_cookie;

import include.nseer_db.nseer_db_backup1;
import java.sql.ResultSet;

public class InsMod
{

	public InsMod()
	{
	}

	public void insert(String mod, String human_ID, String human_name, String file_id, nseer_db_backup1 db)
	{
		if (file_id.length() > 4)
		{
			try
			{
				String sql1 = (new StringBuilder("select id from ")).append(mod).append("_view where human_ID='").append(human_ID).append("' and file_id='").append(file_id).append("'").toString();
				ResultSet rs = db.executeQuery(sql1);
				if (!rs.next())
				{
					sql1 = (new StringBuilder("select * from ")).append(mod).append("_tree where file_id='").append(file_id).append("'").toString();
					rs = db.executeQuery(sql1);
					if (rs.next())
					{
						String sql = (new StringBuilder("insert into ")).append(mod).append("_view(MODULE_NAME,reason,CATEGORY_ID,PARENT_CATEGORY_ID,ACTIVE_STATUS,HREFLINK,FILE_ID,FILE_NAME,DETAILS_TAG,HUMAN_ID,NAME,FILE_PATH) values('").append(rs.getString("MODULE_NAME")).append("','").append(rs.getString("reason")).append("','").append(rs.getString("CATEGORY_ID")).append("','").append(rs.getString("PARENT_CATEGORY_ID")).append("','").append(rs.getString("ACTIVE_STATUS")).append("','").append(rs.getString("HREFLINK")).append("','").append(rs.getString("FILE_ID")).append("','").append(rs.getString("FILE_NAME")).append("','").append(rs.getString("DETAILS_TAG")).append("','").append(human_ID).append("','").append(human_name).append("','").append(rs.getString("FILE_PATH")).append("')").toString();
						db.executeUpdate(sql);
					}
				}
			}
			catch (Exception ex)
			{
				ex.printStackTrace();
			}
			insert(mod, human_ID, human_name, file_id.substring(0, file_id.length() - 2), db);
		} else
		{
			try
			{
				String sql1 = (new StringBuilder("select id from ")).append(mod).append("_view where human_ID='").append(human_ID).append("' and file_id='").append(file_id).append("'").toString();
				ResultSet rs = db.executeQuery(sql1);
				if (!rs.next())
				{
					sql1 = (new StringBuilder("select * from ")).append(mod).append("_tree where file_id='").append(file_id).append("'").toString();
					rs = db.executeQuery(sql1);
					if (rs.next())
					{
						String sql = (new StringBuilder("insert into ")).append(mod).append("_view(MODULE_NAME,reason,CATEGORY_ID,PARENT_CATEGORY_ID,ACTIVE_STATUS,HREFLINK,FILE_ID,FILE_NAME,DETAILS_TAG,HUMAN_ID,NAME,FILE_PATH) values('").append(rs.getString("MODULE_NAME")).append("','").append(rs.getString("reason")).append("','").append(rs.getString("CATEGORY_ID")).append("','").append(rs.getString("PARENT_CATEGORY_ID")).append("','").append(rs.getString("ACTIVE_STATUS")).append("','").append(rs.getString("HREFLINK")).append("','").append(rs.getString("FILE_ID")).append("','").append(rs.getString("FILE_NAME")).append("','").append(rs.getString("DETAILS_TAG")).append("','").append(human_ID).append("','").append(human_name).append("','").append(rs.getString("FILE_PATH")).append("')").toString();
						db.executeUpdate(sql);
					}
				}
			}
			catch (Exception ex)
			{
				ex.printStackTrace();
			}
		}
	}

	public void insertw(String mod, String module_name, String human_ID, nseer_db_backup1 db)
	{
		try
		{
			String sql = (new StringBuilder("select id from security_workspace where human_ID='")).append(human_ID).append("' and view_tree_name='").append(mod).append("'").toString();
			ResultSet rs1 = db.executeQuery(sql);
			if (!rs1.next())
			{
				sql = (new StringBuilder("insert into security_workspace(module_name,view_tree_name,human_ID) values('")).append(module_name).append("','").append(mod).append("','").append(human_ID).append("')").toString();
				db.executeUpdate(sql);
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
